
export const appointStatus = (status: number | undefined) => {
    switch (status) {
        case 1:
            return '已预约'
        case 2:
            return '已就诊'
        default:
            return '已过期/已取消'
    }
}
/**
 * 
 * @param timestamp 
 * @param divider 
 * @returns 
 */
export const dateFmt = (timestamp: any, divider = '/') => {
    const date = new Date(parseInt(timestamp));
    const y = date.getFullYear();
    const m = (date.getMonth() + 1).toString().padStart(2, '0');
    const d = date.getDate().toString().padStart(2, '0');
    const h = date.getHours().toString().padStart(2, '0');
    const mm = date.getMinutes().toString().padStart(2, '0');
    const s = date.getSeconds().toString().padStart(2, '0');
    return `${y}${divider}${m}${divider}${d} ${h}:${mm}:${s}`;
}

/**
 * 手机号码加密
*/
export const phoneEncrypt = (phone: string | number | undefined) => {
    if (typeof phone === undefined) {
        return phone;
    }
    if (typeof phone === 'number') {
        phone = phone.toString();
    }
    const reg = /^(\d{3})\d{4}(\d{4})$/;
    // console.log(phone.replace(reg, "$1****$2"),111);
    return phone?.replace(reg, "$1****$2");
}